import 'package:flutter/material.dart';
import 'package:flutter3x/demo/alert_dialog_demo.dart';
import 'package:flutter3x/demo/bottom_sheet_demo.dart';

import 'package:flutter3x/demo/button_demo.dart';
import 'package:flutter3x/demo/camera_image.dart';
import 'package:flutter3x/demo/checkbox_demo.dart';
import 'package:flutter3x/demo/chip_demo.dart';
import 'package:flutter3x/demo/clock_screen.dart';
import 'package:flutter3x/demo/datatable_demo.dart';
import 'package:flutter3x/demo/datetime_demo.dart';
import 'package:flutter3x/demo/expansion_panel_demo.dart';
import 'package:flutter3x/demo/floating_action_button_demo.dart';
import 'package:flutter3x/demo/getx_demo.dart';
import 'package:flutter3x/demo/image_picker_demo.dart';
import 'package:flutter3x/demo/popmenubutton_demo.dart';
import 'package:flutter3x/demo/form_demo.dart';
import 'package:flutter3x/demo/radio_demo.dart';
import 'package:flutter3x/demo/russiablocks_demo.dart';
import 'package:flutter3x/demo/simple_dialog_demo.dart';
import 'package:flutter3x/demo/slider_demo.dart';
import 'package:flutter3x/demo/snack_bar_demo.dart';
import 'package:flutter3x/demo/switch_demo.dart';
import 'package:flutter3x/demo/sensor_demo.dart';

class MaterialComponents extends StatelessWidget {
  const MaterialComponents({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('MaterialComponents'),
        elevation: 0,
      ),
      body: ListView(
        children: const [
          ListItem(
            title: 'GetX 状态管理',
            page: GetXDemo(),
          ),
          ListItem(
            title: 'RussiaBlocks 俄罗斯方块',
            page: RussiaBlocksDemo(),
          ),
          ListItem(
            title: 'SensorDemo 传感器Demo',
            page: SensorDemo(),
          ),
          ListItem(
            title: 'MyHomePage 官方ImagePicker示例',
            page: MyHomePage(),
          ),
          ListItem(
            title: 'MyIndexedStack 选择照片相机示例测试用',
            page: MyIndexedStack(),
          ),
          ListItem(
            title: 'PopmenuMenuButton 弹出式菜单按钮',
            page: PopupMenuButtonDemo(),
          ),
          ListItem(
            title: 'FloatingActionButton 漂浮动作按钮',
            page: FloatingActionButtonDemo(),
          ),
          ListItem(
            title: 'ButtonDemo 按钮',
            page: ButtonDemo(),
          ),
          ListItem(
            title: 'FormDemo 表单',
            page: FormDemo(),
          ),
          ListItem(
            title: 'CheckboxDemo 复选框and带标签图标文本的复选框',
            page: CheckboxDemo(),
          ),
          ListItem(
            title: 'RadioDemo 单选按钮And带标签图标文本的按钮',
            page: RadioDemo(),
          ),
          ListItem(
            title: 'SwitchDemo 开关功能，以及带标签图标文本的开关',
            page: SwitchDemo(),
          ),
          ListItem(
            title: 'SliderDemo 滑动选择器',
            page: SliderDemo(),
          ),
          ListItem(
            title: 'DateTimeDemo 时间显示页面',
            page: DateTimeDemo(),
          ),
          ListItem(
            title: 'ClockScreen 时钟',
            page: ClockScreen(),
          ),
          ListItem(
            title: 'SimpleDialogDemo 对话框',
            page: SimpleDialogDemo(),
          ),
          ListItem(
            title: 'AlertDialogDemo 提示对话框',
            page: AlertDialogDemo(),
          ),
          ListItem(
            title: 'BottomSheetDemo 底部滑动窗口',
            page: BottomSheetDemo(),
          ),
          ListItem(
            title: 'SnackBarDemo 操作提示栏',
            page: SnackBarDemo(),
          ),
          ListItem(
            title: 'ExpansionPanel 官方案例',
            page: ExpansionPanelListExampleApp(),
          ),
          ListItem(
            title: 'ExpansionPanelDemo 收缩面板',
            page: ExpansionPanelDemo(),
          ),
          ListItem(
            title: 'ChipDemo 小碎片小标签',
            page: ChipDemo(),
          ),
          ListItem(
            title: 'DataTableDemo 数据表格',
            page: DataTableDemo(),
          ),
        ],
      ),
    );
  }
}

// ignore: unused_element
class _WidgetDemo extends StatelessWidget {
  // ignore: unused_element
  const _WidgetDemo({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('_WidgetDemo'),
        elevation: 0,
      ),
      body: Container(
        padding: const EdgeInsets.all(6),
        child: const Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [],
            )
          ],
        ),
      ),
    );
  }
}

class ListItem extends StatelessWidget {
  final String title;
  final Widget page;
  const ListItem({super.key, this.title = '默认Title', required this.page});

  @override
  Widget build(BuildContext context) {
    return ListTile(
      title: Text(title),
      onTap: () {
        Navigator.of(context).push(
          MaterialPageRoute(
            builder: (context) => page,
          ),
        );
      },
    );
  }
}
